
import { LessonService } from "@/shared/api/api.lesson";
import { QueryClient, useMutation, useQueries, useQuery } from "@tanstack/react-query";
import { AxiosError } from "axios";



export function useGetLessonsByThemeId(themeId: number) {
    const queryClient = new QueryClient

    const getLessonsByThemeId = useQuery(
        {
            queryKey: ['lessons-by-theme-id', themeId],
            queryFn: () => LessonService.getByThemeId(themeId),
            retry: 3
        }, queryClient
    );



    return {
        isSuccess: getLessonsByThemeId.isSuccess,
        isLoading: getLessonsByThemeId.isLoading,
        refetch: getLessonsByThemeId.refetch,
        error: getLessonsByThemeId.error,
        lessons: getLessonsByThemeId.data
    };
}